package com.hms.dao.impl;

import org.springframework.stereotype.Component;

import com.hms.dao.IDepartmentDao;
import com.hms.entity.TdDepartment;

/**
 * 标题、简要说明. <br>
 * 类详细说明.
 * <p>
 * Copyright: Copyright (c) 2013-4-13 上午11:37:33
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * 
 * @author wangpz@c-platform.com
 * @version 1.0.0
 */
@Component
public class DepartmentDao extends BaseDao<TdDepartment, String> implements IDepartmentDao {

	@Override
	public String save(TdDepartment entity) {
		String id = super.save(entity);
		TdDepartment parent = entity.getParent();
		if (null != parent) {
			String path = parent.getPath() + TdDepartment.PATH_SPLIT + entity.getPath();
			entity.setPath(path);
			entity.setParent(parent);
		} else {
			entity.setPath(id);
			entity.setParent(entity);
		}
		super.update(entity);
		return id;
	}

	@Override
	public void update(TdDepartment entity) {
//		TdDepartment parent = entity.getParent();
//		if(null!=parent)
//		{
//			
//		}
		super.update(entity);
	}

}
